import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

//      1.科技有若干学生(学生对象放在一个List中)，每个学生有一个姓名(String)、 班级(String)和考试成绩属性(double)
//      某次考试结束后，每个学生都获得了一个考试成绩。遍历list集合，并把学生对象的属性打印出来。
class Student {
    private String name;
    private String classes;
    private double score;

    public Student(String name, String classes, double score) {
        this.name = name;
        this.classes = classes;
        this.score = score;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getClasses() {
        return classes;
    }

    public void setClasses(String classes) {
        this.classes = classes;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return "student{" +
                "name='" + name + '\'' +
                ", classes='" + classes + '\'' +
                ", score=" + score +
                '}';
    }
}
public class TestDemo {

//    可以放任意类型
    public static void main1(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        list.add(new Student("cat","101",123.1));
        list.add(new Student("dog","102",12.1));
        list.add(new Student("pig","103",0.1));
        System.out.println(list);
//        [student{name='cat', classes='101', score=123.1}, student{name='dog', classes='102', score=12.1}, student{name='pig', classes='103', score=0.1}]
    }



//    有一个List当中存放的是整形的数据，要求使用Collections. sort对List进行排序。
//    可以进行排序
    public static void main2(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(12);
        list.add(45);
        list.add(23);
        list.add(3);
        Collections.sort(list);
        System.out.println(list);//[3, 12, 23, 45]
    }


//      2、删除第一个字符串当中出现的第二个字符串中的字符。//面试题
//      String str1 = "welcome to hello world";
//      String str2 = "come";
//      输出结果: wl t hll wrld
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        String str1 = "welcome to hello world";
        String str2 = "come";
        for (int i = 0; i < str1.length(); i++) {
            char ch = str1.charAt(i);
            if (!str2.contains(ch+"")){
                list.add(ch+"");
            }
        }
//        System.out.println(list);//[w, l,  , t,  , h, l, l,  , w, r, l, d]
        for (String str:list) {
            System.out.print(str);//wl t hll wrld
        }

    }


}
